package p.ithorns.tools.translator.sdk;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Description
 *
 * @author yun11
 * @since 2023/10/19
 */
public class TranslatorContextHolder {

    private static final ThreadLocal<Map<String, Object>> THREAD_LOCAL = new ThreadLocal<>() {
        @Override
        protected Map<String, Object> initialValue() {
            return new ConcurrentHashMap<>(1024);
        }
    };

    public static Object get(String key) {
        return THREAD_LOCAL.get().get(key);
    }

    public static void set(String key, Object value) {
        THREAD_LOCAL.get().put(key, value);
    }

    public static void remove() {
        THREAD_LOCAL.remove();
    }
}
